#include "QtImageList.h"

#include <QtGui/QtGui>

QtImageList::QtImageList(QWidget* parent /* = 0 */):
	QListWidget(parent)
{
	setDragEnabled(true);
	setViewMode(QListWidget::IconMode);
	setIconSize(QSize(64,64));
	setSpacing(10);
	//setAcceptDrops(true);
	setDropIndicatorShown(true);
	setFrameStyle(0);
}

QtImageList::~QtImageList()
{

}

void QtImageList::addImage(const QImage& image, const QString& imageName)
{
	QListWidgetItem* item = new QListWidgetItem(this);
	QPixmap pixmap(64,64);
	pixmap.convertFromImage(image);
	item->setIcon(QIcon(pixmap));
	item->setData(Qt::UserRole, imageName);
	//item->setData(Qt::UserRole+1, imageName);
	item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled);
	insertItem(0, item);
}

void QtImageList::dragEnterEvent(QDragEnterEvent *event)
{

}

void QtImageList::dragMoveEvent(QDragMoveEvent *event)
{

}

void QtImageList::dropEvent(QDropEvent *event)
{

}

void QtImageList::startDrag(Qt::DropActions supportedActions)
{

}